﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Text;

namespace FullBinaryTree
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            // Read the file and display it line by line.
            System.IO.StreamReader file =
               new System.IO.StreamReader("in.txt");

            line = file.ReadLine();

            int T = 0;

            if (line != null) T = int.Parse(line.TrimStart().TrimEnd());


            for (int i = 0; i < T; i++)
            {
                line = file.ReadLine();
                int n = 0;
                if (line != null) n = int.Parse(line.TrimStart().TrimEnd());

                Dictionary<int, List<int>> dict = new Dictionary<int, List<int>>();

                for (int j = 0; j < n - 1; j++)
                {
                    line = file.ReadLine();
                    string[] temp = line.Split(' ');
                    int n1 = int.Parse(temp[0]);
                    int n2 = int.Parse(temp[1]);
                    
                    dict[n1].Add(n2);
                    dict[n2].Add(n1);
                }

                for (int j = 1; j <= n; j++)
                {
                    
                }
            }
        }

        static void maxNumber(int n, Dictionary<int, List<int>> dict,List<int> visited,List<int> deleted)
        {
            List<int> childNode = dict[n];

            if (childNode.Count == 0) return;

            if (childNode.Count == 1)  deletedNode(n, dict, visited, deleted);
            if (childNode.Count == 2)
                foreach (int t in childNode)
                {
                    maxNumber(t, dict, visited, deleted);
                }

            if (childNode.Count > 2)
            {
                int m1 = 0, m2 = 0;
                foreach (int t in childNode)
                {
                    if(m2 > )
                }
            }

            return;
        }

        static void deletedNode(int n, Dictionary<int, List<int>> dict, List<int> visited, List<int> deleted)
        {
            
        }
    }
}
